{extend name="base" /}
{block name="body"}
<script type="text/javascript">
    window.onload = function(){
        var E = window.wangEditor;
        var editor = new E('#div1');
        var $text1 = $('#text1');
        editor.customConfig.uploadImgShowBase64 = true;
        editor.customConfig.uploadImgServer = '/api/upload/upload';  // 上传图片到服务器
        editor.customConfig.uploadFileName = 'file';
        editor.customConfig.uploadImgHooks = {
            success: function (xhr, editor, result) {
            },
            customInsert: function (insertImg, result, editor) {
                var url = result.data.src;
                insertImg(url)
            }
        };
        editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $text1.val(html)
        };
        editor.create()
        // 初始化 textarea 的值
        $text1.val(editor.txt.html())

    };
    // 初始化 textarea 的值
</script>
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/article/index')}">文章管理</a></li>
            <li class=""><a href="{:url('admin/article/add')}">添加文章</a></li>
            <li class="layui-this">编辑文章</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/article/update')}" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属栏目</label>
                        <div class="layui-input-block">
                            <select name="cid" lay-verify="required">
                                {foreach name="category_level_list" item="vo"}
                                <option value="{$vo.id}" {if condition="$article.cid==$vo.id"} selected="selected"{/if}>{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' ----';}{/php}{/neq} {$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="{$article.title}" required  lay-verify="required" placeholder="请输入标题" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">作者</label>
                        <div class="layui-input-block">
                            <input type="text" name="author" value="{$article.author}" placeholder="（选填）请输入作者" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item" style="display: none">
                        <label class="layui-form-label">简介</label>
                        <div class="layui-input-block">
                            <textarea name="introduction" placeholder="（选填）请输入简介" class="layui-textarea">{$article.introduction}</textarea>
                        </div>
                    </div>
						  <div class="layui-form-item">
                        <label class="layui-form-label">关键词</label>
                        <div class="layui-input-block">
                           <input type="text" name="keywords" value="{$article.keywords}" placeholder="（选填）请输关键词 ,号隔开" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">内容</label>
                        <div class="layui-input-block">
                            <div id="div1" style="width: 1000px;height: 700px">
                                {$article.content}
                            </div>
                            <!--<textarea id="editor" name="content"    style="width: 1000px;height: 700px">{$article.content}</textarea>-->
                            <textarea id="text1" name="content" style="width:100%; height:200px;display: none"></textarea>
                        </div>
                    </div>
		
                    <div class="layui-form-item">
                        <label class="layui-form-label">缩略图</label>
                        <div class="layui-input-block">
                            <input type="text" name="thumb" value="{$article.thumb}" class="layui-input layui-input-inline" id="thumb">
                            <input type="file" name="file" class="layui-upload-file">
                        </div>
                    </div>
                 <div class="layui-form-item">
                        <label class="layui-form-label">标签</label>
                        <div class="layui-input-block">
                            <input type="radio" name="tag" value="1" title="原创" {if condition="$article.tag==1"} checked="checked"{/if}>
                            <input type="radio" name="tag" value="0" title="转载" {if condition="$article.tag==0"} checked="checked"{/if}>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">发布时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="publish_time" value="{$article.publish_time}" class="layui-input" id="datetime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-block">
                            <input type="text" name="sort" value="{$article.sort}" required  lay-verify="required" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="id" value="{$article.id}">
                            <button class="layui-btn" type="submit">更新</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
